<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用mixin实现多继承</title>
</head>
<body>
    <script>
        function User(name,age){
            this.name = name;
            this.age = age;
        }

        User.prototype.show = function(){
            console.log(this.name,this.age)
        }

        // 将其他方法放到对象在
        const address = {
            getAddress(){
                console.log('地址');
            }
        };

        const request = {
            getRequest(){
                console.log('请求');
            }
        };


        function extend(sub,sup){
            sub.prototype = Object.create(sup.prototype);
            Object.defineProperty(sub.prototype,'constructor',{
                value:sub,
                enumerable:false
            });  
        }


        function Admin(name,age){
            User.call(this,name,age);
        }
        extend(Admin,User); 
        // 将 要使用的对象合并到Admin.prototype中
        Admin.prototype = Object.assign(Admin.prototype,address);
        let admin = new Admin('xiasnn',18);
        admin.show();
        admin.getAddress();



        function Member(name,age){
            User.call(this,name,age);
        }
        extend(Member,User); 
        // 将 要使用的对象合并到Member.prototype中
        Member.prototype = Object.assign(Member.prototype,address,request);
        let member = new Member('xiaxia',19);
        member.show();
        member.getAddress();
        member.getRequest();
    </script>
</body>
</html>